//
//  StudentCell.m
//  CoreDataDemo
//
//  Created by 孙元东 on 2018/3/9.
//  Copyright © 2018年 MuJin. All rights reserved.
//

#import "StudentCell.h"

@interface StudentCell()
@property (weak, nonatomic) IBOutlet UIImageView *leftIcon;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *ageLabel;
@property (weak, nonatomic) IBOutlet UILabel *weightLabel;
@property (weak, nonatomic) IBOutlet UILabel *secLabel;

@end
@implementation StudentCell
//实现类方法
+(instancetype)xibTableViewCell {

    //在类方法中加载xib文件,注意:loadNibNamed:owner:options:这个方法返回的是NSArray,所以在后面加上firstObject或者lastObject或者[0]都可以;因为我们的Xib文件中,只有一个cell
    return [[[NSBundle mainBundle] loadNibNamed:@"StudentCell" owner:nil options:nil] lastObject];
}

-(void)initModelWith:(Person *)model{
    if (model.sex == 0) {
        self.leftIcon.image = [UIImage imageNamed:@"mei"];
        self.secLabel.text = @"帅哥";
    } else {
        self.leftIcon.image = [UIImage imageNamed:@"luo"];
        self.secLabel.text = @"美女";
    }
    self.nameLabel.text = model.name;
    self.ageLabel.text =  [NSString stringWithFormat:@"年龄:%ld",model.age];
    self.weightLabel.text = [NSString stringWithFormat:@"体重:%.2f",model.weight];
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
